<?php

/**
 * Description of Request
 *
 * @author Reinowin7
 */
class Request 
{
    private static $requestAttributesArray = array();
    
    public static function setAttribute($keyInString, $value)
    {
        self::$requestAttributesArray = self::array_push_assoc(self::$requestAttributesArray, $keyInString, $value); 
    }
    
    public static function getParameter($parameterName)
    {
        //Kui parameetri nime massiivis pole, väljasta null
        //$parameterValueReceived = self::$requestAttributesArray[$parameterName];
        
        if (!isset(self::$requestAttributesArray[$parameterName]))
        //if (is_null($parameterValueReceived) or empty($parameterValueReceived))
        {
            return null;
        }
        else
        {
            return self::$requestAttributesArray[$parameterName];
        }
    }
    
    public function getParameterArraySize()
    {
        return count(self::$requestAttributesArray);
    }
    
    public static function getParameterValues($arrayNameConsistingParameters)
    {
        //väljasta null, kui sellist massiivi pole
    }
    
    public static function array_push_assoc($associativeArray, $key, $value)
    {
        $wasArrayChanged = false;
        if (count($associativeArray) > 0)
        {
            foreach ($associativeArray as $label => $valueCorrespondingToLabel)
            {
                if ($label == $key)
                {
                    $associativeArray[$label] = $value;
                    $wasArrayChanged = true;
                }
            }
            if (!$wasArrayChanged)
            {;
                $associativeArray[$key] = $value;
            }
        }
        else
        {
            $associativeArray[$key] = $value;
        }
        
        return $associativeArray;
    }
    
    public function getSession()
    {
        
    }
}

?>
